<?php
/**
 * Created on 29-mag-2006
 * jaco_at_pixeldump
 * creating buttons
 */

include_once("./sample_utils.php");                              // provides some utils and using mk

$swfFN = "button.swf";                                    // the file we'll generate

$btImageFN1 = "gimp_bt_off.png";                          // image for button state off
$btImageFN2 = "gimp_bt_over.png";                         // button state over
$btImageFN3 = "gimp_bt_down.png";                         // state down

$swf = new MKSwf($swfFN);                                 // create a fresh swf
$swf->set_swfDir(SERVER_MKTMP);                           // store in tmp
$swf->set_stage_dimensions(170, 50);                      // stage dimensions
$swf->set_backgroundColor("#0066FF");                     // background color

$img = new BitmapItem();                                 // image object, id = 1 by default
$imgTD = $img->create_from_file($btImageFN1);             // create from image file
$swf->add_tagData($imgTD);                                // tag data
$buttonWidth = $img->get_imageWidth();                    // used for hit area
$buttonHeight = $img->get_imageHeight();                  //

$img = new BitmapItem(2);                                //
$imgTD = $img->create_from_file($btImageFN2);             //
$swf->add_tagData($imgTD);                                //

$img = new BitmapItem(3);                                //
$imgTD = $img->create_from_file($btImageFN3);             //
$swf->add_tagData($imgTD);                                //

$shape1 = new MKShapeContainer("", 4);                   // a shape that bound image #1
$shape1->add_bitmap_fill(1);                              //
$shape1->add_rect(0, 0, $buttonWidth, $buttonHeight);     //
$shapeTD1 = $shape1->update_tagData();                    //
$swf->add_tagData($shapeTD1);                             //

$shape2 = new MKShapeContainer("", 5);                   // bound image #2
$shape2->add_bitmap_fill(2);                              //
$shape2->add_rect(0, 0, $buttonWidth, $buttonHeight);     //
$shapeTD2 = $shape2->update_tagData();                    //
$swf->add_tagData($shapeTD2);                             //

$shape3 = new MKShapeContainer("", 6);                   // bound image #3
$shape3->add_bitmap_fill(3);                              //
$shape3->add_rect(0, 0, $buttonWidth, $buttonHeight);     //
$shapeTD3 = $shape3->update_tagData();                    //
$swf->add_tagData($shapeTD3);                             //

$shape4 = new MKShapeContainer("", 7);                   // hit area, only vector data
$shape4->add_fillStyle_solid();                           // black by default, color is pointless here
$shape4->add_rect(0, 0, $buttonWidth, $buttonHeight);     // use image width/height for hit area
$shapeTD4 = $shape4->update_tagData();                    //
$swf->add_tagData($shapeTD4);                             //

$shapeAr = array($shape4, $shape3, $shape2, $shape1);     // an array with shapes
$button = new MKButtonContainer("", 8);                  // a fresh button
$button->move(10, 10);                                    // place @10,10
$buttonTD = $button->build_from_array($shapeAr);          // use shape array for placing an setting states
$buttonPB = $button->update_place_tagData();              // place tag data
$swf->add_tagData($buttonTD);                             //
$swf->add_tagData($buttonPB);                             //

$swf->swf_output();                                       // save

$swfHeader = $swf->fetch_assoc();                         // prepare to publish

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
